﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WEALTH.Manager.User
{
    public partial class MyProfile : BasePage
    {
        private UserFilter userFilter = new UserFilter();
        private ExcuteDao userManage = new ExcuteDao();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                UserCurrent currentUser = getCurrentUser();
                this.txtUserId.Text = currentUser.UserID;
                this.txtUserName.Text = currentUser.UserName;
                this.txtTel.Text = currentUser.UserPhone;
                this.txtEmail.Text = currentUser.UserEmail;
            }
        }
        /// <summary>
        /// 保存按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            UserCurrent currentUser = getCurrentUser();
            this.userFilter.User_ID = currentUser.UserID;
            this.userFilter.User_Name = this.txtUserName.Text;
            this.userFilter.User_Tel = this.txtTel.Text;
            this.userFilter.User_Mail = this.txtEmail.Text;
            this.userFilter.User_status = "1";
            if (userManage.Update_User(this.userFilter) != 0)
            {
                currentUser.UserName = this.txtUserName.Text;
                currentUser.UserPhone = this.txtTel.Text;
                currentUser.UserEmail = this.txtEmail.Text;
                this.ShowMsg("资料修改成功", 0);
            }
            else
            {
                this.txtUserName.Text = currentUser.UserName;
                this.txtTel.Text = currentUser.UserPhone;
                this.txtEmail.Text = currentUser.UserEmail;
                this.ShowMsg("资料修改失败!", -1);
            }
        }
    }
}